package com.xyhua.houseproperty.service;

import com.google.errorprone.annotations.Var;
import com.xyhua.houseproperty.dao.UserMapper;
import com.xyhua.houseproperty.entity.User;
import com.xyhua.houseproperty.utils.BeanHelper;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import cn.hutool.core.util.XmlUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.XML;
import org.springframework.web.multipart.MultipartFile;

/**
 * description: UserService <br>
 * date: 2020/3/31 3:44 下午 <br>
 * author: huaxiansheng <br>
 * version: 1.0 <br>
 */
@Service
public class UserService {

    @Resource
    UserMapper mUserMapper;

    @Resource
    FileService mFileService;

    public boolean addAcount(User account) {
        account.setPasswd(SecureUtil.md5(account.getPasswd()));
        MultipartFile avatarFile = account.getAvatarFile();
        String avatarPath = mFileService.getImagePath(avatarFile);
        account.setAvatar(avatarPath);
        BeanHelper.setDefaultProp(account, User.class);
        BeanHelper.onInsert(account);
        int i = mUserMapper.addUser(account);
//        发邮件
        
        return i > 0;
    }

}
